<!--
	开发者:宋成恩
	开发时间:2017-7-10
	修改时间:2017-7-10

 -->
<template>
  <div id="showImageCard">
    <img v-if="url === undefined" src="../../assets/img/resume/resume_headpic.png" :width="imageWidth"
         :height="imageHeight">
    <!-- <img v-if="url === undefined" src="../../../static/img/notUpload.png" :width="imageWidth" :height="imageHeight"> -->
    <img v-else :src="rightUrl" :width="imageWidth" :height="imageHeight" @click="openImagePopUp">
  </div>
</template>

<script>
  import { getImgFromServer } from '../../assets/js/post.js'

  export default {
    name: 'showImageCard',
    props: ['url', 'config'],
    data () {
      return {
        rightUrl: '',
        imageWidth: '',
        imageHeight: ''
      }
    },
    created () {
      if (this.url !== undefined && this.url.length > 1) {
        this.getRightUrl()
      }
      if ('width' in this.config) {
        this.imageWidth = this.config.width
      }
      if ('height' in this.config) {
        this.imageHeight = this.config.height
      }
    },
    methods: {
      getRightUrl () {
        this.rightUrl = getImgFromServer('GET_AUTH_FILE', this.url)
      },
      openImagePopUp () {
      },
    },
    watch: {
      url: function (val, oldVal) {
        if (val !== undefined && val.length > 1) {
          this.getRightUrl()
        }
      }
    }
  }
</script>

<style scoped>
</style>
